package com.tempjob.common.businesss.mongo.entity;

import com.anwen.mongo.annotation.ID;
import com.anwen.mongo.annotation.collection.CollectionField;
import com.anwen.mongo.annotation.collection.CollectionName;
import com.anwen.mongo.enums.FieldFill;
import com.anwen.mongo.enums.IdTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tempjob.common.model.IdendCardInfoVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户信息
 */
@CollectionName(value = "user_info")
@Data
public class UserInfo implements Serializable {

    @ID(type = IdTypeEnum.OBJECT_ID)
    @CollectionField("_id")
    private String id;

    @CollectionField(value = "real_name")
    @ApiModelProperty("姓名")
    private String realName;

    @CollectionField(value = "mobile")
    @ApiModelProperty("手机号码")
    private String mobile;

    @CollectionField(value = "salt")
    @ApiModelProperty(hidden = true)
    private String salt;

    @CollectionField(value = "password")
    @ApiModelProperty(hidden = true)
    private String password;

    @CollectionField(value = "ident_no")
    @ApiModelProperty("身份证号码")
    private String identNo;

    @CollectionField(value = "ident_portrait_img")
    @ApiModelProperty("身份证正面图片地址")
    private String identPortraitImg;

    @CollectionField(value = "ident_emblem_img")
    @ApiModelProperty("身份证反面图片地址")
    private String identEmblemImg;

    @CollectionField(value = "idend_card_info")
    @ApiModelProperty("身份证信息")
    private IdendCardInfoVO idendCardInfo;

    @CollectionField(value = "ident_issue_authority")
    @ApiModelProperty("签发机关")
    private String identIssueAuthority;

    @CollectionField(value = "ident_valid_period")
    @ApiModelProperty("有效期限")
    private String identValidPeriod;

    @CollectionField(value = "ident_address")
    @ApiModelProperty("身份证地址")
    private String identAddress;

    @CollectionField(value = "sex")
    @ApiModelProperty("未知男女")
    private String sex;

    @CollectionField(value = "birthday")
    @ApiModelProperty("出生日期")
    private Date birthday;

    @CollectionField(value = "open_id")
    @ApiModelProperty("openid")
    private String openId;

    @CollectionField(value = "union_id")
    @ApiModelProperty("unionId")
    private String unionId;

    @CollectionField(value = "avatar")
    @ApiModelProperty("头像")
    private String avatar;

    @CollectionField(value = "user_status")
    @ApiModelProperty("状态0未认证1已认证")
    private Integer userStatus;

    @ApiModelProperty("学历")
    @CollectionField("education")
    private String education;

    @ApiModelProperty("个人优势")
    @CollectionField("advantage")
    private String advantage;

    @ApiModelProperty("求职状态：1求职中2在职求职")
    @CollectionField("hire_status")
    private Integer hireStatus;

    @ApiModelProperty("参加工作时间yyyy-MM")
    @DateTimeFormat(pattern = "yyyy-MM")
    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
    @CollectionField("start_work_time")
    private Date startWorkTime;

    public Integer getUserStatus() {
        if (userStatus == null) {
            userStatus = 0;
        }
        return userStatus;
    }

    @CollectionField("user_type")
    @ApiModelProperty("身份类型：1找工作2招工")
    private List<Integer> userType;

    @ApiModelProperty("当前身份类型：1找工作2招工")
    private Integer currentType;

    @CollectionField("hire_type")
    @ApiModelProperty("身份类型：1普通用户2个体工商户3公司员工")
    private Integer hireType;

    @CollectionField(value = "company_id")
    @ApiModelProperty("公司id")
    private String companyId;



    @CollectionField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty("更新时间")
    private Date updateTime;

    @CollectionField(value = "last_login_ip")
    @ApiModelProperty(name = "最后登录ip", hidden = true)
    private String lastLoginIp;

    @CollectionField(value = "login_times")
    @ApiModelProperty(name = "登录次数", hidden = true)
    private Integer loginTimes;

    @CollectionField(value = "last_login_time")
    @ApiModelProperty(name = "最后登录时间", hidden = true)
    private Date lastLoginTime;

    @CollectionField(value = "oper_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date operTime;

    @CollectionField(value = "create_time", fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    @CollectionField(exist = false)
    private static final long serialVersionUID = 1L;
}
